;
(function (doc, Comment) {
  // 获取节点
  //立即评论按钮
  var oOpenBtn = doc.getElementsByClassName('J_openBtn')[0],
    //对话框里的右上角关闭按钮
    oCloseBtn = doc.getElementsByClassName('J_closeBtn')[0],
    //星星的盒子
    oStars = doc.getElementsByClassName('J_stars')[0],
    // 输入文本区域
    oEditText = doc.getElementsByClassName('J_editTxt')[0],
    // 提交评论按钮
    oSubmitBtn = doc.getElementsByClassName('J_submitBtn')[0],
    //tab栏：全部/好评/中评/差评
    oRadioTabs = doc.getElementsByClassName('J_radioTabs')[0],
    //分页按钮 1/2/3/.../8/9
    oBtnBox = doc.getElementsByClassName('J_btnBox')[0];

  // 定义一个测试的用户
  var userId = 13;




  var init = function () {
    //加载页面时加载评论列表
    //参数1 id 参数2 页码
    Comment.getComments({
      fieldId: 0,
      pages: 0
    });
    bindEvent();
  }

  function bindEvent() {
    oOpenBtn.addEventListener('click', Comment.openBoard, false);
    oCloseBtn.addEventListener('click', Comment.closeBoard.bind(Comment), false);
    oStars.addEventListener('mouseover', Comment.starsHover, false);
    oEditText.addEventListener('input', Comment.editInput.bind(Comment), false);
    //传参写法
    oSubmitBtn.addEventListener('click', Comment.submitComment.bind(Comment, userId), false);
    oRadioTabs.addEventListener('click', Comment.radioTabClick.bind(Comment), false);
    oBtnBox.addEventListener('click', Comment.pageBtnClick.bind(Comment), false);
  }

  init();

})(document, initCommentModule);